package com.zhuang.principle.ocp;

/**
 * @Classname OpenClosed2
 * @Description 开闭原则正确示范
 * @Date 2021/3/15 14:41
 * @Created by dell
 */

public class OpenClosed2 {

    public static void main(String[] args) {
        GraphicEditor graphicEditor = new GraphicEditor();
        graphicEditor.drawTriangle(new Triangle());
        graphicEditor.drawCircle(new Shape());
        graphicEditor.drawRectangle(new Rectangle());
    }
}


abstract class Shape2{
    int m_type;

    public  abstract void draw();

}
//矩形
class Rectangle2 extends Shape2{
    Rectangle2(){
        super.m_type=1;
    }
    @Override
    public void draw() {
        System.out.println("绘制矩形");
    }
}
//圆形
class Circle2 extends Shape2{
    Circle2(){
        super.m_type=2;
    }
    @Override
    public void draw() {
        System.out.println("绘制圆形");
    }
}
//三角形
class Triangle2 extends Shape2{
    Triangle2(){
        super.m_type=3;
    }
    @Override
    public void draw() {
        System.out.println("绘制三角形");
    }
}